<template>
  <div id="global-sider">
    <MenuUnfoldOutlined class="icon" v-if="collapsed" @click="toggleCollapse" />

    <a-layout-sider
      v-model:collapsed="collapsed"
      :width="280"
      collapsible
      :collapsed-width="0"
      breakpoint="lg"
      :trigger="null"
    >
      <div class="sider-bar">
        <img src="@/assets/vue.svg" alt="" style="height: 36px" />
        <button v-if="!collapsed" @click="toggleCollapse">
          <span>
            <MenuFoldOutlined style="font-size: 20px" />
          </span>
        </button>
      </div>
      <a-menu mode="inline">
        <a-menu-item key="1">菜单项aaaaa</a-menu-item>
        <a-menu-item key="2">菜单项2</a-menu-item>
        <a-menu-item key="3">菜单项3</a-menu-item>
        <a-menu-item key="4">菜单项4</a-menu-item>
        <a-menu-item key="1">菜单项1</a-menu-item>
        <a-menu-item key="2">菜单项2</a-menu-item>
        <a-menu-item key="3">菜单项3</a-menu-item>
        <a-menu-item key="4">菜单项4</a-menu-item>
        <a-menu-item key="1">菜单项1</a-menu-item>
        <a-menu-item key="2">菜单项2</a-menu-item>
        <a-menu-item key="3">菜单项3</a-menu-item>
        <a-menu-item key="4">菜单项4</a-menu-item>
        <a-menu-item key="1">菜单项1</a-menu-item>
        <a-menu-item key="2">菜单项2</a-menu-item>
        <a-menu-item key="3">菜单项3</a-menu-item>
        <a-menu-item key="4">菜单项4</a-menu-item>
        <a-menu-item key="1">菜单项1</a-menu-item>
        <a-menu-item key="2">菜单项2</a-menu-item>
        <a-menu-item key="3">菜单项3</a-menu-item>
        <a-menu-item key="4">菜单项4</a-menu-item>
        <a-menu-item key="1">菜单项1</a-menu-item>
        <a-menu-item key="2">菜单项2</a-menu-item>
        <a-menu-item key="3">菜单项3</a-menu-item>
        <a-menu-item key="4">菜单项4</a-menu-item>
        <a-menu-item key="2">菜单项2</a-menu-item>
        <a-menu-item key="3">菜单项3</a-menu-item>
        <a-menu-item key="2">菜单项2</a-menu-item>
        <a-menu-item key="3">菜单项3</a-menu-item>
        <a-menu-item key="4">菜单项4</a-menu-item>
        <a-menu-item key="1">菜单项1</a-menu-item>
        <a-menu-item key="2">菜单项2</a-menu-item>
        <a-menu-item key="3">菜单项尾</a-menu-item>
      </a-menu>
    </a-layout-sider>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";

import { MenuFoldOutlined, MenuUnfoldOutlined } from "@ant-design/icons-vue";

const collapsed = ref(false);
const toggleCollapse = () => {
  collapsed.value = !collapsed.value;
};
</script>

<style lang="scss" scoped>
#global-sider {
  height: 100%;
  overflow: hidden;
  .icon {
    font-size: 20px;
    cursor: pointer;
    position: absolute;
    top: 80px;
    z-index: 1;
  }
  .sider-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    margin-left: 16px;
    margin-right: 10px;
  }
  .ant-layout-sider {
    height: 100%;
    background: #f5f7fa;

    .ant-menu {
      height: 100%;
      background: #f5f7fa;
      overflow-y: scroll;
      /* 移除滚动条 */
      /* 移除滚动条轨道背景 */

      /* 保留滑块样式 */
      &::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.2);
        border-radius: 10px;
      }
      /* 设置滚动条宽度 */
      &::-webkit-scrollbar {
        width: 6px;
        background: transparent;
      }
    }
  }
}
</style>
